home *** CD-ROM | disk | FTP | other *** search
/ Skunkware 98 / Skunkware 98.iso / src / interp / perl-5.003.tar.gz / perl-5.003.tar / perl-5.003 / pod / buildtoc next >
Text File  |  1996-03-25  |  4KB  |  208 lines

  1. use File::Find;
  2. use Cwd;
  3.  
  4. @pods = qw{
  5.         perl perldata perlsyn perlop perlre perlrun perlfunc perlvar
  6.         perlsub perlmod perlref perldsc perllol perlobj perltie
  7.         perlbot perldebug perldiag perlform perlipc perlsec perltrap
  8.         perlstyle perlxs perlxstut perlguts perlcall perlembed perlpod
  9.         perlbook 
  10.     };
  11. for (@pods) { s/$/.pod/ } 
  12.  
  13. $/ = '';
  14. @ARGV = @pods;
  15.  
  16. ($_= <<EOPOD2B) =~ s/^\t//gm && print;
  17.  
  18.     =head1 NAME
  19.  
  20.     perltoc - perl documentation table of contents
  21.  
  22.     =head1 DESCRIPTION
  23.  
  24.     This page provides a brief table of contents for the rest of the Perl 
  25.     documentation set.  It is meant to be be quickly scanned or grepped 
  26.     through to locate the proper section you're looking for.
  27.  
  28.     =head1 BASIC DOCUMENTATION
  29.  
  30. EOPOD2B
  31.  
  32. podset(@pods);
  33.  
  34. find \&getpods => qw(../lib ../ext);
  35. sub getpods {
  36.     if (/\.p(od|m)$/) { 
  37.     my $tmp;
  38.     # Skip .pm files that have corresponding .pod files, and Functions.pm.
  39.     return if (($tmp = $_) =~ s/\.pm$/.pod/ && -f $tmp);
  40.     return if ($_ eq '../lib/Pod/Functions.pm');####Used only by pod itself
  41.  
  42.     my $file = $File::Find::name;
  43.     die "tut $name" if $file =~ /TUT/;
  44.     unless (open (F, "< $_\0")) {
  45.         warn "bogus <$file>: $!";
  46.         system "ls", "-l", $file;
  47.     }  else { 
  48.         my $line;
  49.         while ($line = <F>) {
  50.         if ($line =~ /^=head1\s+NAME\b/) {
  51.             push @modpods, $file;
  52.             #warn "GOOD $file\n";
  53.             return;
  54.         } 
  55.         } 
  56.         warn "EVIL $file\n";
  57.     }
  58.     }
  59. }
  60.  
  61. die "no pods" unless @modpods;
  62.  
  63. for (@modpods) {
  64.     #($name) = /(\w+)\.p(m|od)$/;
  65.     $name = path2modname($_);
  66.     if ($name =~ /^[a-z]/) {
  67.     push @pragmata, $_;
  68.     } else {
  69.     if ($done{$name}++) {
  70.         # warn "already did $_\n";
  71.         next;
  72.     } 
  73.     push @modules, $_;
  74.     push @modname, $name;
  75.     } 
  76.  
  77. ($_= <<EOPOD2B) =~ s/^\t//gm && print;
  78.  
  79.  
  80.  
  81.     =head1 PRAGMA DOCUMENTATION
  82.  
  83. EOPOD2B
  84.  
  85. podset(sort @pragmata);
  86.  
  87. ($_= <<EOPOD2B) =~ s/^\t//gm && print;
  88.  
  89.  
  90.  
  91.     =head1 MODULE DOCUMENTATION
  92.  
  93. EOPOD2B
  94.  
  95. podset( @modules[ sort { $modname[$a] cmp $modname[$b] } 0 .. $#modules ] );
  96.  
  97. ($_= <<EOPOD2B) =~ s/^\t//gm;
  98.  
  99.  
  100.     =head1 AUXILIARY DOCUMENTATION
  101.  
  102.     Here should be listed all the extra program's docs, but they
  103.     don't all have man pages yet:
  104.  
  105.     =item a2p
  106.  
  107.     =item s2p
  108.  
  109.     =item find2perl
  110.     
  111.     =item h2ph
  112.     
  113.     =item c2ph
  114.  
  115.     =item h2xs
  116.  
  117.     =item xsubpp
  118.  
  119.     =item pod2man 
  120.  
  121.     =item wrapsuid
  122.  
  123.  
  124.     =head1 AUTHOR
  125.  
  126.     Larry Wall E<lt>F<lwall\@sems.com>E<gt>, with the help of oodles 
  127.     of other folks.
  128.  
  129.  
  130. EOPOD2B
  131. print;
  132.  
  133. exit;
  134.  
  135. sub podset {
  136.     local @ARGV = @_;
  137.  
  138.     while(<>) {
  139.     if (s/^=head1 (NAME)\s*/=head2 /) {
  140.         $pod = path2modname($ARGV);
  141.         sub path2modname {
  142.         local $_ = shift;
  143.         s/\.p(m|od)$//;
  144.         s-.*?/(lib|ext)/--;
  145.         s-/-::-g;
  146.         s/(\w+)::\1/$1/;
  147.         return $_;
  148.         }
  149.         unitem(); unhead2();
  150.         print "\n \n\n=head2 ";
  151.         $_ = <>;
  152.         if ( /^\s*$pod\b/ ) {
  153.         print;
  154.         } else {
  155.         s/^/$pod, /;
  156.         print;
  157.         } 
  158.         next;
  159.     }
  160.     if (s/^=head1 (.*)/=item $1/) {
  161.         unitem(); unhead2();
  162.         print; nl(); next;
  163.     } 
  164.     if (s/^=head2 (.*)/=item $1/) {
  165.         unitem();
  166.         print "=over\n\n" unless $inhead2;
  167.         $inhead2 = 1;
  168.         print; nl(); next;
  169.  
  170.     } 
  171.     if (s/^=item (.*)\n/$1/) {
  172.         next if $pod eq 'perldiag';
  173.         s/^\s*\*\s*$// && next;
  174.         s/^\s*\*\s*//;
  175.         s/\s+$//;
  176.         next if /^[\d.]+$/;
  177.         next if $pod eq 'perlmod' && /^ftp:/;
  178.         ##print "=over\n\n" unless $initem;
  179.         print ", " if $initem;
  180.         $initem = 1;
  181.         s/\.$//;
  182.         print; next;
  183.     } 
  184.     } 
  185.  
  186.  
  187. sub unhead2 {
  188.     if ($inhead2) {
  189.     print "\n\n=back\n\n";
  190.     } 
  191.     $inhead2 = 0; 
  192.     $initem = 0;
  193.  
  194. sub unitem {
  195.     if ($initem) {
  196.     print "\n\n";
  197.     ##print "\n\n=back\n\n";
  198.     } 
  199.     $initem = 0;
  200.  
  201. sub nl {
  202.     print "\n";
  203.